<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改角色类别</title>
	<link rel="stylesheet" type="text/css" href="${ctx}/themes/gray/easyui.css">
	<link rel="stylesheet" type="text/css" href="${ctx}/themes/icon.css">
	<script type="text/javascript" src="${ctx}/script/jquery.min.js"></script>
	<script type="text/javascript" src="${ctx}/script/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${ctx}/script/lhgdialog/lhgdialog.min.js?s=facebook"></script>
	<script type="text/javascript" src="${ctx}/script/CheckText.js"></script>
	<script type="text/javascript">
		var dg = frameElement.lhgDG;
		dg.addBtn( 'ok', '确定', function(){ 
			if (!checkFormItem(document.getElementById("lbmc"),"C",50,0,1,"角色名称")) return false;
			if (!checkFormItem(document.getElementById("sm"),"C",50,0,2,"角色说明")) return false;
			submitForm();
		});
		
		function submitForm() {
			var pId = $("#id").val();
			var pLbmc= $("#lbmc").val();
			var pSm = $("#sm").val();
			var params = {
				"gg_czlb.id" : pId,
				"gg_czlb.lbmc" : pLbmc,
				"gg_czlb.sm" : pSm
			};
			var actionUrl = "saveGG_CZLB.action";
			$.ajax( {
				url : actionUrl,
				data : params,
				dataType : "json",
				cache : false,
				error : function(textStatus, errorThrown) {alert("系统ajax交互错误: " + textStatus);},
				success : function(data, textStatus) {
					if (data.ajaxResult == "success") {
						var dataRow = {
							ID: data.gg_czlb.id,
							LBMC: data.gg_czlb.lbmc,
							SM: data.gg_czlb.sm
						};
						if(pId == "") {
							dg.curWin.$("#gridTable").addRowData(data.gg_czlb.id, dataRow, "first");
							new dg.curWin.$.dialog({id:'2',title:'信息提示页面',page:'${ctx}/success.jsp',rang:true,iconTitle:false}).ShowDialog();
							dg.cancel();
							//dg.reDialogSize(500,230);
							//alert("信息添加成功!");
						} else {
							var rowId = dg.curWin.$("#gridTable").getGridParam('selrow');
							dg.curWin.$("#gridTable").setRowData(rowId, dataRow, {color:"#FF0000"});
							//dg.curWin.$("#gridTable").jqGrid('setRowData',data.gg_czlb.id,dataRow,{color:"#FF0000"});
							//dg.reDialogSize(500,230);
							//alert("信息更新成功!");
							new dg.curWin.$.dialog({id:'2',title:'信息提示页面',page:'${ctx}/success.jsp',rang:true,iconTitle:false}).ShowDialog();
							dg.cancel();
						}
						//dg.cancel();
						
					} else {
						dg.curWin.alert("修改操作失败!");
					}
				}
			});
		}
		
		
		$(function(){
			$("#back").click(function() {
				dg.cancel();
			});
			$("#save").click(function() {
				//var rowId = dg.curWin.$("#gridTable").getGridParam('selrow');
				//var rowData = dg.curWin.$("#gridTable").getRowData(rowId);
				//alert("ID: " + rowData.id);
				var pId = $("#id").val();
				var pLbmc= $("#lbmc").val();
				var pSm = $("#sm").val();
				var params = {
					"gg_czlb.id" : pId,
					"gg_czlb.lbmc" : pLbmc,
					"gg_czlb.sm" : pSm
				};
				var actionUrl = "saveGG_CZLB.action";
				$.ajax( {
					url : actionUrl,
					data : params,
					dataType : "json",
					cache : false,
					error : function(textStatus, errorThrown) {alert("系统ajax交互错误: " + textStatus);},
					success : function(data, textStatus) {
						if (data.ajaxResult == "success") {
							var dataRow = {
								id : data.gg_czlb.id,
								lbmc : pLbmc,
								sm : pSm
							};
							if(pId == "") {
								dg.curWin.$("#gridTable").addRowData(data.gg_czlb.id, dataRow, "first");
								alert("信息添加成功!");
							} else {
								dg.curWin.$("#gridTable").setRowData(data.gg_czlb.id, dataRow, {color:"#FF0000"});
								alert("信息更新成功!");
							}
							dg.cancel();
							
						} else {
							dg.curWin.alert("修改操作失败!");
						}
					}
				});
			});
		});
	</script>
</head>
<body>
<form id="ff" method="post">
<input type="hidden" id ="id" name="gg_czlb.id" value="${gg_czlb.id}">
<table id="tt" title="角色信息" iconCls="icon-title">
	<tbody>
	<tr>
		<td>角色名称:</td>
		<td><input id="lbmc"  name="gg_czlb.lbmc" style="width:150px;" value="${gg_czlb.lbmc}"></td>
	</tr>
	<tr>
		<td>角色说明:</td>
		<td><input id="sm" name="gg_czlb.sm" style="width:150px;" value="${gg_czlb.sm}"></td>
	</tr>
	<!-- 
	<tr>
		<td>角色类别:</td>
		<td>
			<select id="roletype" name="gg_czlb.roletype" style="width:200px;" required="true">
				<option value="">请选择</option>
				<option value="2">管理员</option>
				<option value="3">用户</option>
			</select>
		</td>
	</tr>
	 -->
	</tbody>
</table>
<!-- 
<p>
	<input id="save" type="submit" value="保存"/>
	<input id="back" type="button" value="返回"/>
</p>
 -->
</form>
</body>
</html>